package cn.com.dycc.study_manage.integral.controller;

import java.io.UnsupportedEncodingException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dycc.common.controller.BaseController;
import cn.com.dycc.study_manage.integral.param.Pb_Integral_RuleParam;
import cn.com.dycc.study_manage.integral.service.Pb_Integral_RuleService;
import cn.com.dycc.util.JsonObjectResult;
import cn.com.dycc.util.JsonResult;

@Controller
@RequestMapping("/study_manage/integral")
public class Pb_Integral_RuleController extends BaseController{
	
	@Resource
	private Pb_Integral_RuleService pb_Integral_RuleService;
	
	/**
	 * 新增积分规则信息
	 * @param param
	 * @param session
	 * @param request
	 * @return
	 */
	@RequestMapping("/add.do")
	@ResponseBody
	public JsonResult addPb_Integral_Rule(Pb_Integral_RuleParam param,HttpSession session,HttpServletRequest request){
		
		int d=pb_Integral_RuleService.addPb_Integral_Rule(param,request);
		String flag="成功导入数据条数为:"+d;
		return new JsonResult(flag);		
	}
	/**
	 * 更新积分规则信息
	 * @param param
	 * @param request
	 * @param session
	 * @return
	 */
	@RequestMapping("/update.do")
	@ResponseBody
	public JsonResult updatePb_Integral_Rule(Pb_Integral_RuleParam param,HttpServletRequest request,HttpSession session){
		
		int d=pb_Integral_RuleService.updatePb_Integral_Rule(param,request);
		String flag="成功更新数据条数为:"+d;
		return new JsonResult(flag);
	}
	
	
	/**
	 * 查询本组织id下的积分规则信息
	 * @param param
	 * @param session
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/listAll.do")
	@ResponseBody
	public JsonObjectResult findAllPb_Integral_Rule(Pb_Integral_RuleParam param,HttpSession session,HttpServletRequest request) throws UnsupportedEncodingException{
		
		JsonObjectResult result=pb_Integral_RuleService.findPb_Integral_RuleByParam(param,request);
		
		return result;
	}

}
